package com.gxar.navigation.server.base.controller;

import com.gxar.common.entity.Result;
import com.gxar.navigation.server.base.model.activity.request.PreviewRequest;
import com.gxar.navigation.server.base.model.activity.request.PublishRequest;
import com.gxar.navigation.server.base.model.activity.response.PreviewResponse;
import com.gxar.navigation.server.base.model.activity.response.PublishResponse;
import com.gxar.navigation.server.db.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author linsy
 * @version 1.0
 * @created 2023/9/21 09:21
 */
@Api(tags = "导航活动控制器")
@RestController
@RequestMapping("/api/map/activity")
@RequiredArgsConstructor
@Slf4j
public class ActivityController {

    private final ActivityService activityService;

    @ApiOperation("活动预览")
    @PostMapping("/preview")
    @ResponseBody
    public Result<PreviewResponse> preview(@RequestBody PreviewRequest request) {
        PreviewResponse response = activityService.preview(request);
        return Result.success(response);
    }

    @ApiOperation("活动发布")
    @PostMapping("/publish")
    @ResponseBody
    public Result<PublishResponse> publish(@RequestBody PublishRequest request) {
        PublishResponse response = activityService.publish(request);
        return Result.success(response);
    }

}
